package com.sharding.sphere.controller;

import com.sharding.sphere.dao.OrderDao;
import com.sharding.sphere.entity.OrderDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiangminwen
 * @since 2021/8/23 17:37
 */
@RestController
@RequestMapping
public class OrderController {
    @Autowired
    private OrderDao insertUser;

    @RequestMapping("/saveOrder")
    @ResponseBody
    public Boolean saveUser(OrderDO user) {
        System.out.println("saveOrder" + user);
        user.setOrderId(System.currentTimeMillis());
        return insertUser.insertOrder(user) == 1;
    }

    @RequestMapping("/getOrder")
    @ResponseBody
    public List<OrderDO> getOrder(OrderDO order) {
        return insertUser.getOrder(order.getId(), order.getOrderId());
    }

    @RequestMapping("/getAllOrder")
    @ResponseBody
    public List<OrderDO> getAllOrder() {
        return insertUser.getAllOrder();
    }
}
